// Good way of handling invalid method arguments
import  java.util.*;
public class Circle2{
    private static double area(double radius)throws IllegalArgumentException {
        if(radius < 0)
           throw new IllegalArgumentException("Negative radius");
         else
            return  Math.PI *radius * radius;
     }
      public static void main(String[] args){
              Scanner scanner = new Scanner(System.in);
             double circleArea = 0, radius;
             boolean inputError;
            do{
              System.out.printf("Enter  in cm radius >= 0: ");
               try{
                 radius = scanner.nextDouble();
                 circleArea = area(radius);
                 inputError = false;
              }
              catch(IllegalArgumentException e){
              	    System.out.println(e);
                   inputError = true;
              }
              catch(InputMismatchException e){
              	  System.out.println(e);
                  inputError = true;
                  scanner.nextLine();  // clear the input buffer
              }
           } while(inputError);
           System.out.printf("Circle area = %.2f sqr cm %n", circleArea);
       }
}
